{% extends 'admin/base.html' %}

{%load comm_extras %}

{% block head_soruce %}
<script type="text/javascript">
	var urlDelete = '{%url admin-product-delete 88888888 %}';

	function delProduct(itemId){
		if(!confirm('你确定要删除吗？')){return;}
		var url = urlDelete.replace('88888888', itemId);
		$.ajax({
			url: url,
			type: 'get',
			dataType: 'json',
			success: function(result, textStatus){
				if(result){
					if(result.success){
						window.location.reload();
					}else{
						alert(result.err_msg);
					}
				}else{
					alert('删除失败');
				}
			},
			error: function(xhr, textStatus, errorThrown){
			}
		});
	}

</script>
{% endblock %}

{% block main_content %}
	<h1>产品管理</h1>
	<ul id="movie-form" class="form">
	{%for item in items %}
		<li>
			<img src="/static/productimgs/{{item.homeimage.thumburl}}" width="50" height="50" alt="{{item.title}}" />
			<a href="{%url admin-product-edit item.id%}">编辑</a>
			<a href="javascript:void(0)" onclick="delProduct({{item.id}});">删除</a>
			<a target="_blank" href="{%url product-detail-info item.id%}">{{item.title}}</a>
			<a href="{%url admin-tuangou-index item.id%}">管理团购</a>
		</li>
	{%endfor%}
	</ul>
	{% paginator 5 %}
{% endblock %}
